<template>
    <div class="backgroundset">
            <el-table ref="multipleTable" :data="tasklist" tooltip-effect="dark" style="width: 100%" border
                stripe
                 @selection-change="handleSelectionChange"
                :header-cell-style="{ background: '#D8E4F0', color: '#2A303B', fontWeight: '500' }">
                 <el-table-column align="center" type="selection" width="55"> </el-table-column>
                <el-table-column align="center" label="题组">
                    <template slot-scope="scope">
                        {{ scope.row.questionGroupName }}{{ scope.row.questionNumbers || '-' }}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="题型">
                   <template slot-scope="scope">
                        {{ scope.row.questionTypeName || '-' }}
                    </template>
                </el-table-column>
                <el-table-column align="center" label="多评轮次">
                    <template slot-scope="scope">
                        <span @click="rowreviewrounds(scope.row.id,scope.row.reviewRounds)" style="text-decoration: underline;color:#1A48DB;cursor: pointer;">{{ scope.row.reviewRounds==1?'一评':scope.row.reviewRounds==2?'二评':'-' }}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column align="center" label="仲裁设置">
                <template slot-scope="scope">
                    {{ scope.row.createdTime ? scope.row.createdTime : '-' }}
                </template>
                </el-table-column> -->
                <el-table-column align="center" label="工作量系数">
                <template slot-scope="scope">
                    {{ scope.row.workloadFactor ? scope.row.workloadFactor : '-' }}
                </template>
                </el-table-column>
            </el-table>
            <div class="page-bottom">
                <div class="examfooter">
                    <div class="examFootercontent">
                        <div>
                            <span class="totaldata">共<i>{{tasklist.length}}</i>条数据,已选{{ multipleSelection.length }}条</span>
                            <el-button style="background:#1A48DB;color:#fff;margin-left:20px;border-color:#1A48DB;"
                                @click="addtateobjective">批量修改系数</el-button>
                        </div>
                        <!-- <div>
                            <el-pagination
                                background
                                @current-change="handleCurrentChange"
                                :page-sizes="[20, 50,100]"
                                @size-change="handleSizeChange"
                                :page-size="pageSize"
                                layout="sizes, prev, pager, next"
                                :total="total">
                            </el-pagination>
                        </div> -->
                    </div>
                </div>
            </div>
            <!-- 批量修改系数 -->
             <div class="objsubMain" v-if="batchfixedNumberishow">
                <div class="objsubContent">
                    <h3>批量修改系数</h3>
                    <div class="questiongroupvalue">
                        <span>请输入题组系数</span>
                        <el-select v-model="questionGroup" placeholder="1/2/3">
                            <el-option
                                v-for="item in questionGroupoptions"
                                :key="item"
                                :label="item"
                                :value="item">
                            </el-option>
                        </el-select>
                    </div>
                    <div class="objbtnbox">
                        <span @click="alltaskschoolSure">保存</span>
                        <span @click="alltaskschoolBack">返回</span>
                    </div>
                </div>
            </div>
        </div>
</template>

<script>
import {singQuestionassignment,batchclickAllocation} from '@/api/task/task.js'
export default {
    props: {
        tasklist:{
            type:Array,
            default:()=>[]
        }
    },
    data() {
        return {
            evaluationlist:[],
            total:0,
            multipleSelection:[],
            questionGroup:'',
            questionGroupoptions:[1,2,3],
            batchfixedNumberishow:false
        }
    },
    methods:{
        handleSelectionChange (val) {
            this.multipleSelection = val;
        },
         //二平
        rowreviewrounds(id,reviewRounds){
            let obj;
            this.$modal.confirm('确认修改多评轮次，修改后需要进行重新分配任务').then(()=> {
                if (reviewRounds == 1) {
                    obj = {
                    id: id,
                    reviewRounds: 2,
                    };
                } else {
                    obj = {
                    id: id,
                    reviewRounds: 1,
                    };
                }
                singQuestionassignment(obj).then((res) => {
                    if (res.code == 200) {
                    this.$emit("rowreviewrounds", id);
                    this.$message({
                        message: "修改成功",
                        type: "success",
                    });
                    }
                });
            })
        },
        //保存
        alltaskschoolSure(){
            if(this.questionGroup==''){
                this.$message({
                    message:'请输入题组系数',
                    type:'warning'
                })
                return 
            }
            let ids = this.multipleSelection.map(item => {
                return {
                    id: item.id,
                    workloadFactor: this.questionGroup
                };
            });
            batchclickAllocation(ids).then(res=>{
                if(res.code==200){
                    this.batchfixedNumberishow = false
                    this.questionGroup = ''
                     this.$message({
                        message: '批量修改系数成功',
                        type: 'success'
                    })
                    this.$emit('refresh')
                }
            })
        },
        //返回
        alltaskschoolBack(){
             this.batchfixedNumberishow = false
        },
        //批量修改系数
        addtateobjective(){
             if(this.multipleSelection.length==0){
                this.$message({
                    message: '请选择要启用的任务',
                    type: 'warning'
                })
                return
            }
            this.batchfixedNumberishow = true
        }
    }
}
</script>

<style scoped>
.backgroundset{
  padding: 0 15px 15px 15px;
    background:#fff;
}
.custom-table {
  width: 100%;
  border: 1px solid rgba(216, 228, 240, 0.34);
  border-right: none;
  border-bottom: none;
}
/* 自定义表格内部元素的样式 */
.custom-table>>>.el-table__header-wrapper th {
  background-color: #E8F0FA;
  height: 42px;
  padding: 0;
  text-align: center;
  font-weight: normal
}
.custom-table >>> .el-table th.el-table__cell.is-leaf, .custom-table >>> .el-table td.el-table__cell{
    border-bottom:none;
}
.custom-table>>>.el-table__row td {
  height: 42px;
  padding: 0;
  text-align: center;
  border-right: solid 1px rgba(216, 228, 240, 0.5);
  font-size: 14px;
}
.el-table .warning-row {
  background: #ffffff;
}
.el-table .success-row {
  background: #D8E4F0;
}
.el-table .el-table__cell {
  padding: 8px 0;
}
.examfooter {
  width: 100%;
  height: 54px;
  left: 0;
  bottom: 0;
}

.examFootercontent {
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.examFootercontent .totaldata {
  font-size: 14px;
}

.examFootercontent .totaldata i {
  display: inline-block;
  color: #295CFF;
  font-style: normal;
  line-height: 54px;
  padding: 0 3px;
}
.taskredborder{
    display: inline-block;
    width: 62px;
    height: 22px;
    background: #ec555a0f;
    border: 1px solid #ec555a80;
    border-radius: 4px;
    color:#EC555A;
    font-size:14px;
    font-weight: normal;
}
.scopednr b{
    font-weight:normal;
    margin:0 10px;
    color:#1A48DB;
    text-decoration: underline;
    cursor: pointer;
}
.scopednr b.hover{
    color:#EC555A
}
.autoquestion, .avgquestion, .efficiencyquestion{
    display: inline-block;
    width: 76px;
    height: 22px;
    font-size:14px;
    border-radius: 4px;
}
.autoquestion{
    background: #1a48db0f;
    border: 1px solid #1a48db80;
    color:#1A48DB;
}
.avgquestion{
    background: #2f44890f;
    border: 1px solid #2f448980;
    color:#2F4489
}
.efficiencyquestion{
    background: #ca61270f;
    border: 1px solid #ca612780;
    color:#CA6127;
}
.objsubMain {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
}
.objsubContent {
  box-sizing: border-box;
  width: 400px;
  height: 200px;
  background: #FFFFFF;
  box-shadow: 0px 4px 16px 0px rgba(85, 114, 146, 0.1);
  border-radius: 10px;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 24px;
}
.objsubContent h3 {
  font-size: 18px;
  font-weight: normal;
}
.objsubattention {
  display: flex;
  font-size: 14px;
  color: #619CF5;
  padding: 10px 0 24px;
}
.objbtnbox{
    display: flex;
    align-items: center;
    padding-top:15px;
}
.objbtnbox span{
    width: 84px;
    height: 34px;
    background: #1A48DB;
    border-radius: 4px;
    text-align: center;
    line-height:34px;
    color:#fff;
    display: inline-block;
    margin-right:15px;
    cursor: pointer;
    margin-top:10px;
}
.objbtnbox span:last-child{
    background:#EC555A
}
.questiongroupvalue span{
    font-size:14px;
    padding-right:15px;
}
>>> .el-select-dropdown{
    z-index:10000;
}
</style>